<?php 

	class Achievement_Model {
		
		const POST_ONCE = 1;
		const POST_10 = 2;
		const COMMENT_ONCE = 3;
		const COMMENT_20 = 4;
		const ONE_POST_100_LIKES = 5;
		const ONE_POST_100_DISLIKES = 6;
		const EASTER_EGG = 7;
		
		//mendapatkan achievement apa aja yang sudah didapat oleh user
		public function getAllAchievementAchieved($user_id) {
			$res = mysql_query("SELECT *
								FROM achievement
								LEFT JOIN achieving
								ON achievement.ID = achieving.achievement_id
								WHERE user_id = $user_id");
			return $res;
		}								
		
		//mendapatkan daftar achievement yang bisa diraih
		public function getAllAchievement() {
			$res = mysql_query("SELECT *
								FROM achievement");
			return $res;
		}
		
		public function getAchievement($achievement_id) {
			$res = mysql_query("SELECT *
								FROM achievement
								WHERE ID = $achievement_id");
			return $res;
		}	
		
		public function addAchievementToUser($user_id, $achievement_id) {
			$ret = mysql_query("INSERT INTO achieving(user_id, achievement_id)
								VALUES ($user_id, $achievement_id)");
			return $ret;
		}		
	}


?>